package IdManagement;

import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashSet;

public class FriendListDBUtil {
	private static Connection con;
	
	public static HashSet<String> getAllFriends(String id) throws IOException, SQLException{
		String sql="select * from relation where refer like '%s%%'";
		HashSet<String> list=new HashSet<>();
		
		if (con==null) {
			con=DBUtil.getConnection();
		}
		
		Statement state=con.createStatement();
		ResultSet rs=state.executeQuery(String.format(sql,id));
		while(rs.next()) {
			list.add(rs.getString(1).split("_")[1]);
		}
		list.remove(id);
		
		return list;
	}

}
